home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 1999 #5 / 1999 CD 5 (black).iso / Delphi3 / install / data.z / COMMDLG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-04  |  24.1 KB  |  666 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Run-time Library                         }
  5. {       Windows 32bit API Interface Unit                }
  6. {                                                       }
  7. {       Copyright (c) 1995,97 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit CommDlg;
  12.  
  13. {$WEAKPACKAGEUNIT}
  14.  
  15. interface
  16.  
  17. uses Windows, Messages;
  18.  
  19. type
  20.   POpenFilenameA = ^TOpenFilenameA;
  21.   POpenFilenameW = ^TOpenFilenameW;
  22.   POpenFilename = POpenFilenameA;
  23.   TOpenFilenameA = packed record
  24.     lStructSize: DWORD;
  25.     hWndOwner: HWND;
  26.     hInstance: HINST;
  27.     lpstrFilter: PAnsiChar;
  28.     lpstrCustomFilter: PAnsiChar;
  29.     nMaxCustFilter: DWORD;
  30.     nFilterIndex: DWORD;
  31.     lpstrFile: PAnsiChar;
  32.     nMaxFile: DWORD;
  33.     lpstrFileTitle: PAnsiChar;
  34.     nMaxFileTitle: DWORD;
  35.     lpstrInitialDir: PAnsiChar;
  36.     lpstrTitle: PAnsiChar;
  37.     Flags: DWORD;
  38.     nFileOffset: Word;
  39.     nFileExtension: Word;
  40.     lpstrDefExt: PAnsiChar;
  41.     lCustData: LPARAM;
  42.     lpfnHook: function(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  43.     lpTemplateName: PAnsiChar;
  44.   end;
  45.   TOpenFilenameW = packed record
  46.     lStructSize: DWORD;
  47.     hWndOwner: HWND;
  48.     hInstance: HINST;
  49.     lpstrFilter: PWideChar;
  50.     lpstrCustomFilter: PWideChar;
  51.     nMaxCustFilter: DWORD;
  52.     nFilterIndex: DWORD;
  53.     lpstrFile: PWideChar;
  54.     nMaxFile: DWORD;
  55.     lpstrFileTitle: PWideChar;
  56.     nMaxFileTitle: DWORD;
  57.     lpstrInitialDir: PWideChar;
  58.     lpstrTitle: PWideChar;
  59.     Flags: DWORD;
  60.     nFileOffset: Word;
  61.     nFileExtension: Word;
  62.     lpstrDefExt: PWideChar;
  63.     lCustData: LPARAM;
  64.     lpfnHook: function(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  65.     lpTemplateName: PWideChar;
  66.   end;
  67.   TOpenFilename = TOpenFilenameA;
  68.  
  69. function GetOpenFileNameA(var OpenFile: TOpenFilenameA): Bool; stdcall;
  70. function GetOpenFileNameW(var OpenFile: TOpenFilenameW): Bool; stdcall;
  71. function GetOpenFileName(var OpenFile: TOpenFilename): Bool; stdcall;
  72. function GetSaveFileNameA(var OpenFile: TOpenFilenameA): Bool; stdcall;
  73. function GetSaveFileNameW(var OpenFile: TOpenFilenameW): Bool; stdcall;
  74. function GetSaveFileName(var OpenFile: TOpenFilename): Bool; stdcall;
  75. function GetFileTitleA(FileName: PAnsiChar; Title: PAnsiChar; TitleSize: Word): Smallint; stdcall;
  76. function GetFileTitleW(FileName: PWideChar; Title: PWideChar; TitleSize: Word): Smallint; stdcall;
  77. function GetFileTitle(FileName: PChar; Title: PChar; TitleSize: Word): Smallint; stdcall;
  78.  
  79. const
  80.   OFN_READONLY = $00000001;
  81.   OFN_OVERWRITEPROMPT = $00000002;
  82.   OFN_HIDEREADONLY = $00000004;
  83.   OFN_NOCHANGEDIR = $00000008;
  84.   OFN_SHOWHELP = $00000010;
  85.   OFN_ENABLEHOOK = $00000020;
  86.   OFN_ENABLETEMPLATE = $00000040;
  87.   OFN_ENABLETEMPLATEHANDLE = $00000080;
  88.   OFN_NOVALIDATE = $00000100;
  89.   OFN_ALLOWMULTISELECT = $00000200;
  90.   OFN_EXTENSIONDIFFERENT = $00000400;
  91.   OFN_PATHMUSTEXIST = $00000800;
  92.   OFN_FILEMUSTEXIST = $00001000;
  93.   OFN_CREATEPROMPT = $00002000;
  94.   OFN_SHAREAWARE = $00004000;
  95.   OFN_NOREADONLYRETURN = $00008000;
  96.   OFN_NOTESTFILECREATE = $00010000;
  97.   OFN_NONETWORKBUTTON = $00020000;
  98.   OFN_NOLONGNAMES = $00040000;
  99.   OFN_EXPLORER = $00080000;
  100.   OFN_NODEREFERENCELINKS = $00100000;
  101.   OFN_LONGNAMES = $00200000;
  102.  
  103. { Return values for the registered message sent to the hook function
  104.   when a sharing violation occurs.  OFN_SHAREFALLTHROUGH allows the
  105.   filename to be accepted, OFN_SHARENOWARN rejects the name but puts
  106.   up no warning (returned when the app has already put up a warning
  107.   message), and OFN_SHAREWARN puts up the default warning message
  108.   for sharing violations.
  109.  
  110.   Note:  Undefined return values map to OFN_SHAREWARN, but are
  111.          reserved for future use. }
  112.  
  113.   OFN_SHAREFALLTHROUGH = 2;
  114.   OFN_SHARENOWARN = 1;
  115.   OFN_SHAREWARN = 0;
  116.  
  117. type
  118.   POFNotifyA = ^TOFNotifyA;
  119.   POFNotifyW = ^TOFNotifyW;
  120.   POFNotify = POFNotifyA;
  121.   TOFNotifyA = packed record
  122.     hdr: TNMHdr;
  123.     lpOFN: POpenFilenameA;
  124.     pszFile: PAnsiChar;
  125.   end;
  126.   TOFNotifyW = packed record
  127.     hdr: TNMHdr;
  128.     lpOFN: POpenFilenameW;
  129.     pszFile: PWideChar;
  130.   end;
  131.   TOFNotify = TOFNotifyA;
  132.  
  133. const
  134.   CDN_FIRST = -601;
  135.   CDN_LAST = -699;
  136.  
  137. { Notifications when Open or Save dialog status changes }
  138.  
  139.   CDN_INITDONE = CDN_FIRST - 0;
  140.   CDN_SELCHANGE = CDN_FIRST - 1;
  141.   CDN_FOLDERCHANGE = CDN_FIRST - 2;
  142.   CDN_SHAREVIOLATION = CDN_FIRST - 3;
  143.   CDN_HELP = CDN_FIRST - 4;
  144.   CDN_FILEOK = CDN_FIRST - 5;
  145.   CDN_TYPECHANGE = CDN_FIRST - 6;
  146.  
  147.   CDM_FIRST = WM_USER + 100;
  148.   CDM_LAST = WM_USER + 200;
  149.  
  150. { Messages to query information from the Open or Save dialogs }
  151.  
  152. { lParam = pointer to text buffer that gets filled in
  153.   wParam = max number of characters of the text buffer (including NULL)
  154.   return = < 0 if error; number of characters needed (including NULL) }
  155.  
  156.   CDM_GETSPEC = CDM_FIRST + 0;
  157.  
  158. { lParam = pointer to text buffer that gets filled in
  159.   wParam = max number of characters of the text buffer (including NULL)
  160.   return = < 0 if error; number of characters needed (including NULL) }
  161.  
  162.   CDM_GETFILEPATH = CDM_FIRST + 1;
  163.  
  164. { lParam = pointer to text buffer that gets filled in
  165.   wParam = max number of characters of the text buffer (including NULL)
  166.   return = < 0 if error; number of characters needed (including NULL) }
  167.  
  168.   CDM_GETFOLDERPATH = CDM_FIRST + 2;
  169.  
  170. { lParam = pointer to ITEMIDLIST buffer that gets filled in
  171.   wParam = size of the ITEMIDLIST buffer
  172.   return = < 0 if error; length of buffer needed }
  173.  
  174.   CDM_GETFOLDERIDLIST = CDM_FIRST + 3;
  175.  
  176. { lParam = pointer to a string
  177.   wParam = ID of control to change
  178.   return = not used }
  179.  
  180.   CDM_SETCONTROLTEXT = CDM_FIRST + 4;
  181.  
  182. { lParam = not used
  183.   wParam = ID of control to change
  184.   return = not used }
  185.  
  186.   CDM_HIDECONTROL = CDM_FIRST + 5;
  187.  
  188. { lParam = pointer to default extension (no dot)
  189.   wParam = not used
  190.   return = not used }
  191.  
  192.   CDM_SETDEFEXT = CDM_FIRST + 6;
  193.  
  194. type
  195.   PChooseColorA = ^TChooseColorA;
  196.   PChooseColorW = ^TChooseColorW;
  197.   PChooseColor = PChooseColorA;
  198.   TChooseColorA = packed record
  199.     lStructSize: DWORD;
  200.     hWndOwner: HWND;
  201.     hInstance: HWND;
  202.     rgbResult: COLORREF;
  203.     lpCustColors: ^COLORREF;
  204.     Flags: DWORD;
  205.     lCustData: LPARAM;
  206.     lpfnHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  207.     lpTemplateName: PAnsiChar;
  208.   end;
  209.   TChooseColorW = packed record
  210.     lStructSize: DWORD;
  211.     hWndOwner: HWND;
  212.     hInstance: HWND;
  213.     rgbResult: COLORREF;
  214.     lpCustColors: ^COLORREF;
  215.     Flags: DWORD;
  216.     lCustData: LPARAM;
  217.     lpfnHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  218.     lpTemplateName: PWideChar;
  219.   end;
  220.   TChooseColor = TChooseColorA;
  221.  
  222. function ChooseColorA(var CC: TChooseColorA): Bool; stdcall;
  223. function ChooseColorW(var CC: TChooseColorW): Bool; stdcall;
  224. function ChooseColor(var CC: TChooseColor): Bool; stdcall;
  225.  
  226. const
  227.   CC_RGBINIT = $00000001;
  228.   CC_FULLOPEN = $00000002;
  229.   CC_PREVENTFULLOPEN = $00000004;
  230.   CC_SHOWHELP = $00000008;
  231.   CC_ENABLEHOOK = $00000010;
  232.   CC_ENABLETEMPLATE = $00000020;
  233.   CC_ENABLETEMPLATEHANDLE = $00000040;
  234.   CC_SOLIDCOLOR = $00000080;
  235.   CC_ANYCOLOR = $00000100;
  236.  
  237. type
  238.   PFindReplaceA = ^TFindReplaceA;
  239.   PFindReplaceW = ^TFindReplaceW;
  240.   PFindReplace = PFindReplaceA;
  241.   TFindReplaceA = packed record
  242.     lStructSize: DWORD;        { size of this struct $20 }
  243.     hWndOwner: HWND;             { handle to owner's window }
  244.     hInstance: HINST;        { instance handle of.EXE that
  245.                                    contains cust. dlg. template }
  246.     Flags: DWORD;                { one or more of the fr_?? }
  247.     lpstrFindWhat: PAnsiChar;       { ptr. to search string    }
  248.     lpstrReplaceWith: PAnsiChar;    { ptr. to replace string   }
  249.     wFindWhatLen: Word;          { size of find buffer      }
  250.     wReplaceWithLen: Word;       { size of replace buffer   }
  251.     lCustData: LPARAM;           { data passed to hook fn.  }
  252.     lpfnHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  253.                                  { ptr. to hook fn. or nil }
  254.     lpTemplateName: PAnsiChar;     { custom template name     }
  255.   end;
  256.   TFindReplaceW = packed record
  257.     lStructSize: DWORD;        { size of this struct $20 }
  258.     hWndOwner: HWND;             { handle to owner's window }
  259.     hInstance: HINST;        { instance handle of.EXE that
  260.                                    contains cust. dlg. template }
  261.     Flags: DWORD;                { one or more of the fr_?? }
  262.     lpstrFindWhat: PWideChar;       { ptr. to search string    }
  263.     lpstrReplaceWith: PWideChar;    { ptr. to replace string   }
  264.     wFindWhatLen: Word;          { size of find buffer      }
  265.     wReplaceWithLen: Word;       { size of replace buffer   }
  266.     lCustData: LPARAM;           { data passed to hook fn.  }
  267.     lpfnHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  268.                                  { ptr. to hook fn. or nil }
  269.     lpTemplateName: PWideChar;     { custom template name     }
  270.   end;
  271.   TFindReplace = TFindReplaceA;
  272.  
  273. const
  274.   FR_DOWN = $00000001;
  275.   FR_WHOLEWORD = $00000002;
  276.   FR_MATCHCASE = $00000004;
  277.   FR_FINDNEXT = $00000008;
  278.   FR_REPLACE = $00000010;
  279.   FR_REPLACEALL = $00000020;
  280.   FR_DIALOGTERM = $00000040;
  281.   FR_SHOWHELP = $00000080;
  282.   FR_ENABLEHOOK = $00000100;
  283.   FR_ENABLETEMPLATE = $00000200;
  284.   FR_NOUPDOWN = $00000400;
  285.   FR_NOMATCHCASE = $00000800;
  286.   FR_NOWHOLEWORD = $00001000;
  287.   FR_ENABLETEMPLATEHandle = $00002000;
  288.   FR_HIDEUPDOWN = $00004000;
  289.   FR_HIDEMATCHCASE = $00008000;
  290.   FR_HIDEWHOLEWORD = $00010000;
  291.  
  292. function FindTextA(var FindReplace: TFindReplaceA): HWND; stdcall;
  293. function FindTextW(var FindReplace: TFindReplaceW): HWND; stdcall;
  294. function FindText(var FindReplace: TFindReplace): HWND; stdcall;
  295. function ReplaceTextA(var FindReplace: TFindReplaceA): HWND; stdcall;
  296. function ReplaceTextW(var FindReplace: TFindReplaceW): HWND; stdcall;
  297. function ReplaceText(var FindReplace: TFindReplace): HWND; stdcall;
  298.  
  299. type
  300.   PChooseFontA = ^TChooseFontA;
  301.   PChooseFontW = ^TChooseFontW;
  302.   PChooseFont = PChooseFontA;
  303.   TChooseFontA = packed record
  304.     lStructSize: DWORD;
  305.     hWndOwner: HWnd;            { caller's window handle }
  306.     hDC: HDC;                   { printer DC/IC or nil }
  307.     lpLogFont: PLogFontA;     { pointer to a LOGFONT struct }
  308.     iPointSize: Integer;        { 10 * size in points of selected font }
  309.     Flags: DWORD;               { dialog flags }
  310.     rgbColors: COLORREF;        { returned text color }
  311.     lCustData: LPARAM;          { data passed to hook function }
  312.     lpfnHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  313.                                 { pointer to hook function }
  314.     lpTemplateName: PAnsiChar;    { custom template name }
  315.     hInstance: HINST;       { instance handle of EXE that contains
  316.                                   custom dialog template }
  317.     lpszStyle: PAnsiChar;         { return the style field here
  318.                                   must be lf_FaceSize or bigger }
  319.     nFontType: Word;            { same value reported to the EnumFonts
  320.                                   call back with the extra fonttype_
  321.                                   bits added }
  322.     wReserved: Word;
  323.     nSizeMin: Integer;          { minimum point size allowed and }
  324.     nSizeMax: Integer;          { maximum point size allowed if
  325.                                   cf_LimitSize is used }
  326.   end;
  327.   TChooseFontW = packed record
  328.     lStructSize: DWORD;
  329.     hWndOwner: HWnd;            { caller's window handle }
  330.     hDC: HDC;                   { printer DC/IC or nil }
  331.     lpLogFont: PLogFontW;     { pointer to a LOGFONT struct }
  332.     iPointSize: Integer;        { 10 * size in points of selected font }
  333.     Flags: DWORD;               { dialog flags }
  334.     rgbColors: COLORREF;        { returned text color }
  335.     lCustData: LPARAM;          { data passed to hook function }
  336.     lpfnHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  337.                                 { pointer to hook function }
  338.     lpTemplateName: PWideChar;    { custom template name }
  339.     hInstance: HINST;       { instance handle of EXE that contains
  340.                                   custom dialog template }
  341.     lpszStyle: PWideChar;         { return the style field here
  342.                                   must be lf_FaceSize or bigger }
  343.     nFontType: Word;            { same value reported to the EnumFonts
  344.                                   call back with the extra fonttype_
  345.                                   bits added }
  346.     wReserved: Word;
  347.     nSizeMin: Integer;          { minimum point size allowed and }
  348.     nSizeMax: Integer;          { maximum point size allowed if
  349.                                   cf_LimitSize is used }
  350.   end;
  351.   TChooseFont = TChooseFontA;
  352.  
  353. function ChooseFontA(var ChooseFont: TChooseFontA): Bool; stdcall;
  354. function ChooseFontW(var ChooseFont: TChooseFontW): Bool; stdcall;
  355. function ChooseFont(var ChooseFont: TChooseFont): Bool; stdcall;
  356.  
  357. const
  358.   CF_SCREENFONTS = $00000001;
  359.   CF_PRINTERFONTS = $00000002;
  360.   CF_BOTH = CF_SCREENFONTS OR CF_PRINTERFONTS;
  361.   CF_SHOWHELP = $00000004;
  362.   CF_ENABLEHOOK = $00000008;
  363.   CF_ENABLETEMPLATE = $00000010;
  364.   CF_ENABLETEMPLATEHANDLE = $00000020;
  365.   CF_INITTOLOGFONTSTRUCT = $00000040;
  366.   CF_USESTYLE = $00000080;
  367.   CF_EFFECTS = $00000100;
  368.   CF_APPLY = $00000200;
  369.   CF_ANSIONLY = $00000400;
  370.   CF_SCRIPTSONLY = CF_ANSIONLY;
  371.   CF_NOVECTORFONTS = $00000800;
  372.   CF_NOOEMFONTS = CF_NOVECTORFONTS;
  373.   CF_NOSIMULATIONS = $00001000;
  374.   CF_LIMITSIZE = $00002000;
  375.   CF_FIXEDPITCHONLY = $00004000;
  376.   CF_WYSIWYG = $00008000; { must also have CF_SCREENFONTS & CF_PRINTERFONTS }
  377.   CF_FORCEFONTEXIST = $00010000;
  378.   CF_SCALABLEONLY = $00020000;
  379.   CF_TTONLY = $00040000;
  380.   CF_NOFACESEL = $00080000;
  381.   CF_NOSTYLESEL = $00100000;
  382.   CF_NOSIZESEL = $00200000;
  383.   CF_SELECTSCRIPT = $00400000;
  384.   CF_NOSCRIPTSEL = $00800000;
  385.   CF_NOVERTFONTS = $01000000;
  386.  
  387. { these are extra nFontType bits that are added to what is returned to the
  388.   EnumFonts callback routine }
  389.  
  390.   SIMULATED_FONTTYPE = $8000;
  391.   PRINTER_FONTTYPE = $4000;
  392.   SCREEN_FONTTYPE = $2000;
  393.   BOLD_FONTTYPE = $0100;
  394.   ITALIC_FONTTYPE = $0200;
  395.   REGULAR_FONTTYPE = $0400;
  396.  
  397.   WM_CHOOSEFONT_GETLOGFONT = WM_USER + 1;
  398.   WM_CHOOSEFONT_SETLOGFONT = WM_USER + 101; { removed in 4.0 SDK }
  399.   WM_CHOOSEFONT_SETFLAGS   = WM_USER + 102; { removed in 4.0 SDK }
  400.  
  401. { strings used to obtain unique window message for communication
  402.   between dialog and caller }
  403.  
  404.   LBSELCHSTRING = 'commdlg_LBSelChangedNotify';
  405.   SHAREVISTRING = 'commdlg_ShareViolation';
  406.   FILEOKSTRING  = 'commdlg_FileNameOK';
  407.   COLOROKSTRING = 'commdlg_ColorOK';
  408.   SETRGBSTRING  = 'commdlg_SetRGBColor';
  409.   FINDMSGSTRING = 'commdlg_FindReplace';
  410.   HELPMSGSTRING = 'commdlg_help';
  411.  
  412. { HIWORD values for lParam of commdlg_LBSelChangeNotify message }
  413.  
  414. const
  415.   CD_LBSELNOITEMS = -1;
  416.   CD_LBSELCHANGE  = 0;
  417.   CD_LBSELSUB     = 1;
  418.   CD_LBSELADD     = 2;
  419.  
  420. type
  421.   PPrintDlgA = ^TPrintDlgA;
  422.   PPrintDlgW = ^TPrintDlgW;
  423.   PPrintDlg = PPrintDlgA;
  424.   TPrintDlgA = packed record
  425.     lStructSize: DWORD;
  426.     hWndOwner: HWND;
  427.     hDevMode: HGLOBAL;
  428.     hDevNames: HGLOBAL;
  429.     hDC: HDC;
  430.     Flags: DWORD;
  431.     nFromPage: Word;
  432.     nToPage: Word;
  433.     nMinPage: Word;
  434.     nMaxPage: Word;
  435.     nCopies: Word;
  436.     hInstance: HINST;
  437.     lCustData: LPARAM;
  438.     lpfnPrintHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  439.     lpfnSetupHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  440.     lpPrintTemplateName: PAnsiChar;
  441.     lpSetupTemplateName: PAnsiChar;
  442.     hPrintTemplate: HGLOBAL;
  443.     hSetupTemplate: HGLOBAL;
  444.   end;
  445.   TPrintDlgW = packed record
  446.     lStructSize: DWORD;
  447.     hWndOwner: HWND;
  448.     hDevMode: HGLOBAL;
  449.     hDevNames: HGLOBAL;
  450.     hDC: HDC;
  451.     Flags: DWORD;
  452.     nFromPage: Word;
  453.     nToPage: Word;
  454.     nMinPage: Word;
  455.     nMaxPage: Word;
  456.     nCopies: Word;
  457.     hInstance: HINST;
  458.     lCustData: LPARAM;
  459.     lpfnPrintHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  460.     lpfnSetupHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  461.     lpPrintTemplateName: PWideChar;
  462.     lpSetupTemplateName: PWideChar;
  463.     hPrintTemplate: HGLOBAL;
  464.     hSetupTemplate: HGLOBAL;
  465.   end;
  466.   TPrintDlg = TPrintDlgA;
  467.  
  468. function PrintDlgA(var PrintDlg: TPrintDlgA): Bool; stdcall;
  469. function PrintDlgW(var PrintDlg: TPrintDlgW): Bool; stdcall;
  470. function PrintDlg(var PrintDlg: TPrintDlg): Bool; stdcall;
  471.  
  472. const
  473.   PD_ALLPAGES = $00000000;
  474.   PD_SELECTION = $00000001;
  475.   PD_PAGENUMS = $00000002;
  476.   PD_NOSELECTION = $00000004;
  477.   PD_NOPAGENUMS = $00000008;
  478.   PD_COLLATE = $00000010;
  479.   PD_PRINTTOFILE = $00000020;
  480.   PD_PRINTSETUP = $00000040;
  481.   PD_NOWARNING = $00000080;
  482.   PD_RETURNDC = $00000100;
  483.   PD_RETURNIC = $00000200;
  484.   PD_RETURNDEFAULT = $00000400;
  485.   PD_SHOWHELP = $00000800;
  486.   PD_ENABLEPRINTHOOK = $00001000;
  487.   PD_ENABLESETUPHOOK = $00002000;
  488.   PD_ENABLEPRINTTEMPLATE = $00004000;
  489.   PD_ENABLESETUPTEMPLATE = $00008000;
  490.   PD_ENABLEPRINTTEMPLATEHANDLE = $00010000;
  491.   PD_ENABLESETUPTEMPLATEHANDLE = $00020000;
  492.   PD_USEDEVMODECOPIES = $00040000;
  493.   PD_USEDEVMODECOPIESANDCOLLATE = $00040000;
  494.   PD_DISABLEPRINTTOFILE = $00080000;
  495.   PD_HIDEPRINTTOFILE = $00100000;
  496.   PD_NONETWORKBUTTON = $00200000;
  497.  
  498. type
  499.   PDevNames = ^TDevNames;
  500.   TDevNames = record
  501.     wDriverOffset: Word;
  502.     wDeviceOffset: Word;
  503.     wOutputOffset: Word;
  504.     wDefault: Word;
  505.   end;
  506.  
  507. const
  508.   DN_DEFAULTPRN = $0001;
  509.  
  510. function CommDlgExtendedError: DWORD; stdcall;
  511.  
  512. const
  513.   WM_PSD_PAGESETUPDLG     = WM_USER;
  514.   WM_PSD_FULLPAGERECT     = WM_USER + 1;
  515.   WM_PSD_MINMARGINRECT    = WM_USER + 2;
  516.   WM_PSD_MARGINRECT       = WM_USER + 3;
  517.   WM_PSD_GREEKTEXTRECT    = WM_USER + 4;
  518.   WM_PSD_ENVSTAMPRECT     = WM_USER + 5;
  519.   WM_PSD_YAFULLPAGERECT   = WM_USER + 6;
  520.  
  521. type
  522.   PPageSetupDlgA = ^TPageSetupDlgA;
  523.   PPageSetupDlgW = ^TPageSetupDlgW;
  524.   PPageSetupDlg = PPageSetupDlgA;
  525.   TPageSetupDlgA = packed record
  526.     lStructSize: DWORD;
  527.     hwndOwner: HWND;
  528.     hDevMode: HGLOBAL;
  529.     hDevNames: HGLOBAL;
  530.     Flags: DWORD;
  531.     ptPaperSize: TPoint;
  532.     rtMinMargin: TRect;
  533.     rtMargin: TRect;
  534.     hInstance: HINST;
  535.     lCustData: LPARAM;
  536.     lpfnPageSetupHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  537.     lpfnPagePaintHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  538.     lpPageSetupTemplateName: PAnsiChar;
  539.     hPageSetupTemplate: HGLOBAL;
  540.   end;
  541.   TPageSetupDlgW = packed record
  542.     lStructSize: DWORD;
  543.     hwndOwner: HWND;
  544.     hDevMode: HGLOBAL;
  545.     hDevNames: HGLOBAL;
  546.     Flags: DWORD;
  547.     ptPaperSize: TPoint;
  548.     rtMinMargin: TRect;
  549.     rtMargin: TRect;
  550.     hInstance: HINST;
  551.     lCustData: LPARAM;
  552.     lpfnPageSetupHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  553.     lpfnPagePaintHook: function(Wnd: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  554.     lpPageSetupTemplateName: PWideChar;
  555.     hPageSetupTemplate: HGLOBAL;
  556.   end;
  557.   TPageSetupDlg = TPageSetupDlgA;
  558.  
  559. function PageSetupDlgA(var PgSetupDialog: TPageSetupDlgA): BOOL; stdcall;
  560. function PageSetupDlgW(var PgSetupDialog: TPageSetupDlgW): BOOL; stdcall;
  561. function PageSetupDlg(var PgSetupDialog: TPageSetupDlg): BOOL; stdcall;
  562.  
  563. const
  564.   PSD_DEFAULTMINMARGINS             = $00000000; { default (printer's) }
  565.   PSD_INWININIINTLMEASURE           = $00000000; { 1st of 4 possible }
  566.  
  567.   PSD_MINMARGINS                    = $00000001; { use caller's }
  568.   PSD_MARGINS                       = $00000002; { use caller's }
  569.   PSD_INTHOUSANDTHSOFINCHES         = $00000004; { 2nd of 4 possible }
  570.   PSD_INHUNDREDTHSOFMILLIMETERS     = $00000008; { 3rd of 4 possible }
  571.   PSD_DISABLEMARGINS                = $00000010;
  572.   PSD_DISABLEPRINTER                = $00000020;
  573.   PSD_NOWARNING                     = $00000080; { must be same as PD_* }
  574.   PSD_DISABLEORIENTATION            = $00000100;
  575.   PSD_RETURNDEFAULT                 = $00000400; { must be same as PD_* }
  576.   PSD_DISABLEPAPER                  = $00000200;
  577.   PSD_SHOWHELP                      = $00000800; { must be same as PD_* }
  578.   PSD_ENABLEPAGESETUPHOOK           = $00002000; { must be same as PD_* }
  579.   PSD_ENABLEPAGESETUPTEMPLATE       = $00008000; { must be same as PD_* }
  580.   PSD_ENABLEPAGESETUPTEMPLATEHANDLE = $00020000; { must be same as PD_* }
  581.   PSD_ENABLEPAGEPAINTHOOK           = $00040000;
  582.   PSD_DISABLEPAGEPAINTING           = $00080000;
  583.   PSD_NONETWORKBUTTON               = $00200000; { must be same as PD_* }
  584.  
  585.  
  586. { Common dialog error return codes }
  587.  
  588. const
  589.   CDERR_DIALOGFAILURE    = $FFFF;
  590.  
  591.   CDERR_GENERALCODES     = $0000;
  592.   CDERR_STRUCTSIZE       = $0001;
  593.   CDERR_INITIALIZATION   = $0002;
  594.   CDERR_NOTEMPLATE       = $0003;
  595.   CDERR_NOHINSTANCE      = $0004;
  596.   CDERR_LOADSTRFAILURE   = $0005;
  597.   CDERR_FINDRESFAILURE   = $0006;
  598.   CDERR_LOADRESFAILURE   = $0007;
  599.   CDERR_LOCKRESFAILURE   = $0008;
  600.   CDERR_MEMALLOCFAILURE  = $0009;
  601.   CDERR_MEMLOCKFAILURE   = $000A;
  602.   CDERR_NOHOOK           = $000B;
  603.   CDERR_REGISTERMSGFAIL  = $000C;
  604.  
  605.   PDERR_PRINTERCODES     = $1000;
  606.   PDERR_SETUPFAILURE     = $1001;
  607.   PDERR_PARSEFAILURE     = $1002;
  608.   PDERR_RETDEFFAILURE    = $1003;
  609.   PDERR_LOADDRVFAILURE   = $1004;
  610.   PDERR_GETDEVMODEFAIL   = $1005;
  611.   PDERR_INITFAILURE      = $1006;
  612.   PDERR_NODEVICES        = $1007;
  613.   PDERR_NODEFAULTPRN     = $1008;
  614.   PDERR_DNDMMISMATCH     = $1009;
  615.   PDERR_CREATEICFAILURE  = $100A;
  616.   PDERR_PRINTERNOTFOUND  = $100B;
  617.   PDERR_DEFAULTDIFFERENT = $100C;
  618.  
  619.   CFERR_CHOOSEFONTCODES  = $2000;
  620.   CFERR_NOFONTS          = $2001;
  621.   CFERR_MAXLESSTHANMIN   = $2002;
  622.  
  623.   FNERR_FILENAMECODES    = $3000;
  624.   FNERR_SUBCLASSFAILURE  = $3001;
  625.   FNERR_INVALIDFILENAME  = $3002;
  626.   FNERR_BUFFERTOOSMALL   = $3003;
  627.  
  628.   FRERR_FINDREPLACECODES = $4000;
  629.   FRERR_BUFFERLENGTHZERO = $4001;
  630.  
  631.   CCERR_CHOOSECOLORCODES = $5000;
  632.  
  633. implementation
  634.  
  635. function GetOpenFileNameA;      external 'comdlg32.dll'  name 'GetOpenFileNameA';
  636. function GetOpenFileNameW;      external 'comdlg32.dll'  name 'GetOpenFileNameW';
  637. function GetOpenFileName;      external 'comdlg32.dll'  name 'GetOpenFileNameA';
  638. function GetSaveFileNameA;   external 'comdlg32.dll'  name 'GetSaveFileNameA';
  639. function GetSaveFileNameW;   external 'comdlg32.dll'  name 'GetSaveFileNameW';
  640. function GetSaveFileName;   external 'comdlg32.dll'  name 'GetSaveFileNameA';
  641. function GetFileTitleA;      external 'comdlg32.dll'  name 'GetFileTitleA';
  642. function GetFileTitleW;      external 'comdlg32.dll'  name 'GetFileTitleW';
  643. function GetFileTitle;      external 'comdlg32.dll'  name 'GetFileTitleA';
  644. function ChooseColorA;       external 'comdlg32.dll'  name 'ChooseColorA';
  645. function ChooseColorW;       external 'comdlg32.dll'  name 'ChooseColorW';
  646. function ChooseColor;       external 'comdlg32.dll'  name 'ChooseColorA';
  647. function FindTextA;          external 'comdlg32.dll'  name 'FindTextA';
  648. function FindTextW;          external 'comdlg32.dll'  name 'FindTextW';
  649. function FindText;          external 'comdlg32.dll'  name 'FindTextA';
  650. function ReplaceTextA;       external 'comdlg32.dll'  name 'ReplaceTextA';
  651. function ReplaceTextW;       external 'comdlg32.dll'  name 'ReplaceTextW';
  652. function ReplaceText;       external 'comdlg32.dll'  name 'ReplaceTextA';
  653. function ChooseFontA;        external 'comdlg32.dll'  name 'ChooseFontA';
  654. function ChooseFontW;        external 'comdlg32.dll'  name 'ChooseFontW';
  655. function ChooseFont;        external 'comdlg32.dll'  name 'ChooseFontA';
  656. function PrintDlgA;          external 'comdlg32.dll'  name 'PrintDlgA';
  657. function PrintDlgW;          external 'comdlg32.dll'  name 'PrintDlgW';
  658. function PrintDlg;          external 'comdlg32.dll'  name 'PrintDlgA';
  659. function CommDlgExtendedError; external 'comdlg32.dll'  name 'CommDlgExtendedError';
  660. function PageSetupDlgA;      external 'comdlg32.dll'  name 'PageSetupDlgA';
  661. function PageSetupDlgW;      external 'comdlg32.dll'  name 'PageSetupDlgW';
  662. function PageSetupDlg;      external 'comdlg32.dll'  name 'PageSetupDlgA';
  663.  
  664. end.
  665.  
  666.